//package udp_client;
//import java.io.IOException;
//import java.net.DatagramPacket;
//import java.net.DatagramSocket;
//import java.net.InetAddress;
//import java.net.InetSocketAddress;
//import java.net.SocketException;
//
//
//public class UdpServerSocket {
//    private byte[] buffer = new byte[1024];
//    
//    private DatagramSocket ds = null;
//
//    private DatagramPacket packet = null;
//
//    private InetSocketAddress socketAddress = null;
//
//    private String orgIp;
//
//    public UdpServerSocket(int port) throws Exception {
//        ds = new DatagramSocket(port);
//        System.out.println("server is starting!");
//    }
//    
//    public final String getOrgIp() {
//        return orgIp;
//    }
//
//    public final void setSoTimeout(int timeout) throws Exception {
//        ds.setSoTimeout(timeout);
//    }
//
//    public final int getSoTimeout() throws Exception {
//        return ds.getSoTimeout();
//    }
//
//    public final void bind(String host, int port) throws SocketException {
//        socketAddress = new InetSocketAddress(host, port);
//        ds = new DatagramSocket(socketAddress);
//    }
//
//    public final void receive() throws IOException {
//        packet = new DatagramPacket(buffer, buffer.length);
//        ds.receive(packet);
//        orgIp = packet.getAddress().getHostAddress();
////        String info = new String(packet.getData(), 0, packet.getLength());
//        byte[] array= packet.getData();
//        int upper= (int)array[0]+128;
//        int lower= (int)array[1]+128;
//        System.out.println("received message：" + upper*255+lower);
////        return;
//    }
//
//    public final void response(String info) throws IOException, InterruptedException {
//        System.out.println("client address : " + packet.getAddress().getHostAddress()
//                + ",port：" + packet.getPort());
//        DatagramPacket dp = new DatagramPacket(buffer, buffer.length, packet
//                .getAddress(), packet.getPort());
////        dp.setData(info.getBytes());
////        dp.setData(new byte[300]);
////        ds.send(dp);
////        Scanner cin=new Scanner(System.in);
////        String information= cin.nextLine();
////        Thread.sleep(10);
////        dp.setData(new byte[200]);
////        ds.send(dp);
//    }
//
//    public final void setLength(int bufsize) {
//        packet.setLength(bufsize);
//    }
//
//    public final InetAddress getResponseAddress() {
//        return packet.getAddress();
//    }
//
//    public final int getResponsePort() {
//        return packet.getPort();
//    }
//
//    public final void close() {
//        try {
//            ds.close();
//        } catch (Exception ex) {
//            ex.printStackTrace();
//        }
//    }
//
//    public static void main(String[] args) throws Exception {
//        int serverPort = 9877;
//        DatagramSocket ds= new DatagramSocket(serverPort);
//        System.out.println("server is starting!");
//        
//        myReceive temp_reveive=new myReceive(ds);
//        Thread receive= new Thread(temp_reveive);
//        receive.start();
//        
//        myGather temp_gather=new myGather();
//        Thread gather= new Thread(temp_gather);
//        gather.start();
//        
//        myDisplay temp_display=new myDisplay();
//        Thread display= new Thread(temp_display);
//        display.start();
//        
//    }
//}